<template>
  <div>
    <h1>我的页面</h1>
    <component :is="comName"></component>
    <p>
      <a href="/#/index">主页</a><br>
      <a href="/#/movie">电影</a>
    </p>
  </div>
</template>

<script>
import MyHome from './views/MyHome.vue'
import MyMovie from './views/MyMovie.vue'
export default {
  mounted(){
    window.onhashchange = () => {
      // console.log(window.location.hash);
      const { hash } = window.location
      if(hash==='#/index'){
        this.comName = 'MyHome'
      }else if(hash==='#/movie'){
        this.comName = 'MyMovie'
      }
    }
  },
  data() {
    return {
      comName:'MyHome'
    }
  },
  components:{
    MyHome,
    MyMovie
  }
}
</script>